Crate cjson[][src]

Expand description

A canonical JSON serializer that tries to be compliant with [the OLPC minimal specification for canonical JSON][olpc]. Additionally, the implementation also tries to be fully compatible with the [Go canonical JSON implementation][docker/go/canonical] used across the Docker and Notary ecosystem. Example - reading a JSON file and printing its canonical representation:

let data = r#"
{
    "name": "John Doe",
    "age": 43,
    "phones": [
        "+44 1234567",
        "+44 2345678"
    ]
}"#;
let res: serde_json::Value =
    serde_json::from_str(data).expect("cannot deserialize input file");

let canonical = cjson::to_string(&res).expect("cannot write canonical JSON");
let expected = r#"{"age":43,"name":"John Doe","phones":["+44 1234567","+44 2345678"]}"#;
assert_eq!(canonical, expected);

Enums

This enum represents all errors that can be returned when trying to serialize something as canonical JSON.

Functions

Serialize the given data structure as a String of canonical JSON.

Serialize the given data structure as a canonical JSON byte vector.

Serialize the given data structure as canonical JSON into the IO stream.